//
//  XPBaseView.swift
//  PPKit
//
//  Created by xiaopin on 16/8/31.
//  Copyright © 2016年 pinguo. All rights reserved.
//  https://gitee.com/xiaopindev/PPKit
//  https://github.com/xiaopindev
//  https://xiaopin.cnblogs.com

import UIKit

@objcMembers
class XPBaseView: UIView,NibLoadable {
    /// 临时属性x,y,width,height
    var tempX:CGFloat = 0,tempY:CGFloat=0,tempW:CGFloat = 0,tempH:CGFloat = 0
    /// 是否正在操作中
    var isActioning:Bool = false
    
    var baseVC:XPBaseViewController?
    
    //代码初始化调用
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        initData()
        DispatchQueue.main.async {
            self.initNotification()
            self.initSubViews()
            self.loadData()
        }
    }
    
    //xib初始化调用
    required init?(coder aDecoder: NSCoder) {
        try? super.init(coder: aDecoder)
        
        initData()
        DispatchQueue.main.async {
            self.initSubViews()
            self.loadData()
        }
    }
    
    override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
        super.traitCollectionDidChange(previousTraitCollection)
        if #available(iOS 13.0, *) {
            if traitCollection.hasDifferentColorAppearance(comparedTo: previousTraitCollection){
                PPLog("XPBaseView hasDifferentColorAppearance")
                themeModeChanged()
            }
        }
    }
    
    ///初始化数据
    func initData() {
   
    }
    
    func initNotification() {
   
    }
    
    ///初始化控件
    func initSubViews(){
        
    }
    
    func loadData(){
        
    }
    
    func themeModeChanged(){
        
    }
    
    /// 添加向左划手势
    func addSwipeLeftGesture(){
        
    }
    
    /// 添加向右划手势
    func addSwipeRightGesture(){
        
    }
    
    ///滑动手势
    func swipeGesture(gesture:UISwipeGestureRecognizer){
        
    }
}
